<template>
	<view>
		<view>
			<view style="margin-top: 30upx; background-color: #F0F4F6; border: 1upx solid #CCCCCC;border-radius: 20upx;height: 100upx;width: 90%;margin-left: 5%;display: flex;line-height: 100upx;">
				<view class="" style="height: 100upx;line-height: 100upx;width: 30%;margin-left: 10%;font-weight: 550;font-size: 32upx;">
					易通值剩余
				</view>
				<input type="text" disabled v-model="tzz_release" style="height: 100upx;width: 50%;" />
				<!-- <text style="font-weight: 550;margin-right: 10%;">CNY</text> -->
			</view>
			<view style="margin-top: 30upx; background-color: #F0F4F6; border: 1upx solid #CCCCCC;border-radius: 20upx;height: 100upx;width: 90%;margin-left: 5%;display: flex;line-height: 100upx;">
				<view class="" style="height: 100upx;line-height: 100upx;width: 30%;margin-left: 10%;font-weight: 550;font-size: 32upx;">
					卖出数量
				</view>
				<input type="text" v-model="num" style="height: 100upx;width: 50%;" /><!-- <text style="font-weight: 550;margin-right: 8%;">USDT</text> -->
			</view>
			<!-- <view style="margin-top: 30upx; background-color: #F0F4F6; border: 1upx solid #CCCCCC;border-radius: 20upx;height: 100upx;width: 90%;margin-left: 5%;display: flex;line-height: 100upx;">
				<view class="" style="height: 100upx;line-height: 100upx;width: 30%;margin-left: 10%;font-weight: 550;font-size: 32upx;">
					兑换算力
				</view>
				<input type="text" disabled v-model="zichan_power" style="height: 100upx;width: 50%;" />
				<text style="font-weight: 550;margin-right: 10%;">CNY</text>
			</view> -->
		</view>
		<view>
			<button @click="getsale" type="default" style="width: 90%;margin-left: 5%;background-color: #05052B;margin-top: 30upx;color: #fff;font-weight: 550;">立即挂卖</button>
		</view>
		<view class="container" style="margin-top: 30upx;">
			<!-- <view class="all_add">累计奖励 + {{topres}} 元</view> -->
			<!-- 带上拉加载的数据列表 -->
			<view class="big-loading-text loading-text" style="height: 80upx;line-height: 80upx;text-align: center;border-bottom: 1upx solid #ccc;border-top: 1upx solid #ccc;">
				<text>我的挂单</text>
			</view>
			<!-- 数据列表 -->
			<scroll-view scroll-y="true" style="height: 900upx;">
				<view v-if="list.length == 0" style="text-align: center;font-size: 34upx;color: #B81738;font-weight: 550;">
					暂无数据
				</view>
				<view v-for="(item,key) in list" :key="key" style="background-color: #fff; height: 170upx;box-shadow: 2upx 2upx 10upx #CCCCCC;margin: 20upx;padding: 30upx;">
					<view class="" style="display: flex;">
						<text>挂卖时间:{{item.time}}</text>
						<!-- <text>{{item.id}}</text> -->
						<!-- <text>交易中:{{item.dnum}}</text> -->
					</view>
					<view class="" style="display: flex;justify-content: space-between;line-height: 75upx;">
						<text>当前算力:{{item.price}}</text>
						<text>总数量:{{item.znum}}</text>
						<!-- <text>算力:{{item.price}}</text> -->
					</view>
					<view class="" style="display: flex;justify-content: space-between;">
						<text>已交易:{{item.ynum}}</text>
						<!-- <text>{{item.id}}</text> -->
						<text>状态:{{item.status}}</text>
					</view>
				</view>
			</scroll-view>
		</view>
	</view>
</template>
<script>
import uniLoadMore from '../../../components/uni-load-more.vue';
	export default {
		components: {
			uniLoadMore
		},
		data() {
			return {
				tzz_release:'',
				zichan_power:'',
				evaluate:'',
				openid:'',
				num:'',
				price:'',
				list:[],
			}
		},
		onLoad: function(e) {
			uni.getStorage({
				key: 'openid',
				success: (res) => {
					this.openid = res.data
					this.getdata()
					this.getsale1()
					//页面一加载时请求一次数据`
					// uni.hideLoading()
				},
				fail: () => {
					uni.navigateTo({
						url: '../login/login'
					});
				}
			});
		},
		// 下拉刷新
		onPullDownRefresh() {
			
		},
		// 上拉加载
		onReachBottom(){
			
		},
		methods: {
			getdata() {
				uni.request({
					url: this.$BASE_URL+'/index.php?i=2&c=entry&m=ewei_shopv2&do=mobile&r=member.tzz_exchange.sale&app=1',
					method: 'POST',
					data: {
						'openid':this.openid,
					},
					header:{'Content-Type':'application/x-www-form-urlencoded'},
					success:(res) => {
						console.log(res)
						this.tzz_release = res.data.tzz_release
					},
					fail: () => {},
					complete: () => {}
				});
			},
			//卖出
			getsale(){
				uni.request({
					url: this.$BASE_URL+'/index.php?i=2&c=entry&m=ewei_shopv2&do=mobile&r=member.tzz_exchange.sale_sumbit&app=1',
					method: 'POST',
					data: {
						'openid':this.openid,
						'num':this.num,
						// 'price': this.zichan_power,
						},
					header:{'Content-Type':'application/x-www-form-urlencoded'},
					success: (res) => {
						console.log(res)
						uni.showToast({
							title:res.data.result.message,
							icon:'none'
						})
						setTimeout(()=> {
							uni.navigateTo({
								url:'tzz'
							})
						}, 1000);
					}
				})
			},
			getsale1(){
				uni.request({
					url: this.$BASE_URL+'/index.php?i=2&c=entry&m=ewei_shopv2&do=mobile&r=member.bz_exchange.my_sale_list&app=1',
					method: 'POST',
					data: {
						'openid':this.openid,
						'type':1,
						},
					header:{'Content-Type':'application/x-www-form-urlencoded'},
					success: (res) => {
						console.log(res)
						this.list = res.data.list
					}
				})
			},
		},
	}
</script>

<style>
	page {background-color: #fff;}
</style>
